<template>
  <div class="info-container">
    <div class="asset-name"><span>{{ changeAssets.facilityName }}</span><i class="el-icon-close" @click="closeInfoWindow"></i></div>
    <div class="asset-content">
      <div class="map-row">
        <span class="title">定位類型：</span>
        <span class="context">衛星定位</span>
      </div>

      <div class="map-row">
        <span class="title">定位時間：</span>
        <span class="context">{{ createTime }}</span>
      </div>

      <div class="map-row">
        <span class="title">速度：</span>
        <span class="context">{{ changeAssets.speed }}Km/h</span>
      </div>

      <div class="map-row">
        <span class="title">定位地點：</span>
        <span class="context">{{ changeAssets.mileageStatistics / 1000 }}</span>
      </div>
    </div>
  </div>
</template>

<script>
import AssetsDetails from './assets-details'
import OrderDetails from './order-details'
import { mapState } from 'vuex'
import { timestampToTime } from '@/utils/tools'

export default {
  name: 'old-time-info-window',

  components: {
    [AssetsDetails.name]: AssetsDetails,
    [OrderDetails.name]: OrderDetails
  },

  props: {
    //info: 设备IMEI
    info: [String, Number]
  },

  data() {
    return {
      isOpenAssetsDetail: false,
      isOpenOrderDetail: false
    }
  },

  computed: {
    ...mapState({
      changeAssets: (state) => state.map.changeAssets,
    }),

    createTime: function() {
      return this.changeAssets.createTime ? window.Tools.timestampToTime(this.changeAssets.createTime) : ''
    }
  },

  mounted() {
    // console.log(this.changeAssets,5)
  },

  methods: {
    showInfo(info) {
      console.log('点到我了')
      this.$emit('clickshow', info)
    },

    closeInfoWindow() {
      this.$emit('closeInfoWindow')
    },
  }
}
</script>

<style scoped lang="scss">
@import "@/assets/css/them.scss";

.info-container {
  display: inline-block;
  width: 340px;
  border: 1px solid #aaa;
  background-color: #f9f9f9;
  border-radius: 4px;
  padding: 4px 0px;
  box-shadow: 2px 2px 2px #888888;

  .asset-name {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 15px;
    font-weight: bolder;
    border-bottom: 1px solid #ddd;
  }

  .asset-content {
    background-color: #ffffff;

    .map-row {
      display: flex;
      flex-wrap: nowrap;
      justify-content: left;
      padding: 6px 15px;

      .title {
        padding-right: 5px;
        text-align: right;
        width: 80px;
        display: inline-block;
      }

      .context {
        text-align: left;
        display: inline-block;
      }
    }
  }
}
</style>
